CxProlog - testes semanticos



DICT


dict(NONSENSE) ::: false.


dict(5) ::: false.


dict_new(X), dict(X) ::: true.


-----------------------------------


DICT_SET


dict_new(X), dict_set(X, 5, term) ::: true.


dict_new(X), dict_set(X, 5, term), dict_set(X, 5, term2) ::: true.


dict_new(X), dict_set(X, 5, TERM) ::: true. // funcionalidade da versao futura


-----------------------------------


DICT_GET


dict_new(X), dict_set(X, 5, term), dict_get(X, 5, term) ::: true.


dict_new(X), dict_get(X, 5, term) ::: false.



-----------------------------------


DICT_NEW


dict_new(X) ::: true.



-----------------------------------


DICT_CLEAR


dict_new(X), dict_clear(X) ::: true.


dict_new(X), dict_clear(X), dict_get(X, 5, T) ::: false.



-----------------------------------


DICT_DELETE


dict_new(X), dict_delete(X) ::: true.


dict_new(X), dict_delete(X), dict_clear(X) ::: throw(_).



-----------------------------------



DICT_DELETE_ITEM


dict_new(X), dict_set(X, 5, term), dict_delete_item(X, 5) ::: true.


dict_new(X), dict_delete_item(X, 5) ::: false.


dict_new(X), dict_set(X, 5, term), dict_delete_item(X, 5), dict_get(X, 5, _) ::: fail.



-----------------------------------


DICT_AS_LIST


dict_new(A), dict_set(A, 5, term1), dict_Set(A, a, term2), dict_as_list(A, [5-term1,a-term2] ::: true.